// import { logOut } from '../api/logOut'
import request from 'request'

const USER_KEY = 'User'
const TOKEN_KEY = 'Token'

export function getUser() {
  const user = window.localStorage.getItem(USER_KEY)
  if (user === null) {
    return undefined
  } else {
    return JSON.parse(user)
  }
}

export function setUser(user) {
  window.localStorage.setItem(USER_KEY, JSON.stringify(user))
}

export function removeUser() {
  window.localStorage.removeItem(USER_KEY)
}

export function getToken() {
  const token = window.localStorage.getItem(TOKEN_KEY)
  if (token === null) {
    return undefined
  } else {
    return token
  }
}

export function setToken(token) {
  window.localStorage.setItem(TOKEN_KEY, token)
}
export function removeToken() {
  window.localStorage.removeItem(TOKEN_KEY)
}
export function logout(userid) {
  logOut(userid).then(res => {
  }).catch(e => {
  })
}
